<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
		<!-- 一定先引入jq -->
		<script src="js/jquery-1.10.1.js"></script>
		<script src="js/bootstrap.js"></script>
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="col-sm-6 col-lg-3">
					111
				</div>
				<div class="col-sm-6 col-lg-3">
					222
				</div>
				<div class="col-sm-6 col-lg-3">
					333
				</div>
				<div class="col-sm-6 col-lg-3">
					444
				</div>
				<div class="col-sm-6 col-lg-3">
					555
				</div>
				<div class="col-sm-6 col-lg-3">
					666
				</div>
				<div class="col-sm-6 col-lg-3">
					777
				</div>
				<div class="col-sm-6 col-lg-3">
					888
				</div>
			</div>
		</div>
		<hr />
		<div>
			<button class="btn btn-primary" data-toggle="modal" data-target="#myModal">Modal</button>
		</div>
		<div class="modal fade" tabindex="-1" id="myModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h5 class="modal-title">标题！</h5>
						<button class="close" data-dismiss="modal">&times;</button>
					</div>
					<div class="modal-body">
						<table id="ctable" class="table table-danger">
						</table>
					</div>
					<div class="modal-footer">
						<button class="btn btn-secondary" data-dismiss="modal">取消</button>
						<button class="btn btn-primary">确定</button>
					</div>
				</div>
			</div>
		</div>
		<script>
			
			$('#myModal').on('shown.bs.modal', function () {
				// jquery 的 方法
				$.ajax({
					url: 'https://www.fastmock.site/mock/ed95e4b607f3acb7ca765c9a0283c571/api/goods/all',
					type: 'get',
					data: null,
					data: 'json', // susccess是什么方式解析
					success: function(data) {
						
						data.data.forEach((n, i) => {
							// ajax 成功时回调
							$("#ctable").append(`<tr><td>${n.title}</td><td>${n.price}</td></tr>`)
							
							
							
						})
						
					}
					
					
				})
			})
			
		</script>
		<table class="table table-danger">
			<tr>
				<td>1</td>
				<td>2</td>
			</tr>
			<tr>
				<td>1</td>
				<td>2</td>
			</tr>
			
		</table>
	</body>
</html>
